<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/echarts.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/main.js" type="text/javascript" charset="utf-8"></script>

	<body>
		<div id="main" style="width: 900px;height: 500px;"></div>
	</body>

</html>
<script type="text/javascript">
var balanceArr = [];
var balanceDateArr=[];	
var lengthArr=[]
	var balanceData=[];
		$.ajax({
		type: "get",
		url: "/wechat_mt5/monitor/balance",
		data: {
			mtLogin: 50001,
			sort: "time"
		},
		success: function(data) {
			console.log(balanceArr)
			for(x in data.data) {
				var str = date2(data.data[x].time)
				
//				balanceArr.push({name:str,value:{0:str,1:data.data[x].balance}})
				lengthArr.push("")
				balanceArr.push({name:str,value:data.data[x].balance})
//				balanceDateArr.push(str,)
//				today_Three();

			}
			console.log(lengthArr)
			//			
			var myChart = echarts.init(document.getElementById('main'));

			function randomData() {
				now = new Date(+now + oneDay);
				value = value + Math.random() * 21 - 10;
				return {
					name: now.toString(),
					value: [
						[now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
						Math.round(value)
					]
				}
			}

			var data = [];
			var now = new Date(1997, 9, 3);
			var oneDay = 24 * 3600 * 1000;
			var value = Math.random() * 1000;
			for(var i = 0; i < 1000; i++) {
				data.push(randomData());
				
			}
      console.log(data)
      
			option = {
				
				tooltip: {
					trigger: 'axis',
					formatter: function(params) {
						params = params[0];
						return params.data.name+"  "+params.data.value
					},
					axisPointer: {
						animation: false
					}
				},
				xAxis: {
					type: 'category',
					data: lengthArr,
				},
				yAxis: {
					type: 'value',
					min: function(value) {
						console.log(value)
						return value.min - 100;
					},
					max: function(value) {
						return value.max + 100;
					}
				},
				series: [{
					data: balanceArr,
					type: 'line',

				}]
			};

			
			//			//			
			myChart.setOption(option);

		}
	});
</script>